﻿using AutoMapper;
using GiaSu.DataAccess.Entity;
using GiaSu.DataAccess.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GiaSu.Bussiness.Business.Implement
{
    public class SubjectBusinessImpl : ISubjectBusiness
    {
        private readonly IGenericRepository<Subject> subjectRepository;

        public SubjectBusinessImpl(IGenericRepository<Subject> subjectRepository)
        {
            this.subjectRepository = subjectRepository;
        }

        public IList<Subject> GetAll()
        {
            return Mapper.Map<List<Subject>, List<Subject>>(this.subjectRepository.GetAll().ToList());
        }

        public Subject GetById(int id)
        {
            return this.subjectRepository.FindBy(m => m.Id == id).FirstOrDefault();
        }
    }
}
